package com.zxl.controller;

import com.alibaba.druid.util.StringUtils;
import com.github.pagehelper.PageInfo;
import com.zxl.entity.Emp;
import com.zxl.service.IEmpService;
import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


/**
 * @packageName com.zxl.controller
 * @ClassName
 * @Author zxl
 * @Description //TODO
 * @date
 **/
@Controller
@RequestMapping("/emp")
public class EmpController {

    @Resource
    private IEmpService empService;

    @RequestMapping("/list")
    public String findAll(Integer pageIndex, Integer pageSize, Model model) {
        if (pageIndex == null) {
            pageIndex = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        PageInfo<Emp> all = empService.findAll(pageIndex, pageSize);
        model.addAttribute("emps", all);
        return "list";
    }

    @RequestMapping("/add")
    public String add(Emp emp) {

        return "redirect:/emp/list";
    }

}
